package com.ulife.category.dao.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ulife.category.dao.CategoryDao;
import com.ulife.category.dao.dataobject.CategoryDo;

public class CategoryDaoImpl extends SqlMapClientDaoSupport implements CategoryDao {

	public int insertCategory(CategoryDo cateDo) throws SQLException {
		return getSqlMapClient().update("Category.insertCategory",cateDo);
	}

	public int updateCategory(CategoryDo cateDo) throws SQLException {
		return getSqlMapClient().update("Category.updateCategory",cateDo);
	}

	@SuppressWarnings("unchecked")
	public List<CategoryDo> queryAllEnableCategoryByParentId(Long cParentid) throws SQLException {
		Map<String,Long> param = new HashMap<String, Long>();
		param.put("cParentid", cParentid);
		return getSqlMapClient().queryForList("Category.queryAllEnableCategoryByParentId",param);
	}
	
	@SuppressWarnings("unchecked")
	public List<CategoryDo> queryAllEnableCategory() throws SQLException {
		return getSqlMapClient().queryForList("Category.queryAllEnableCategory");
	}

	public CategoryDo queryCategoryById(Long cateId) throws SQLException {
		return (CategoryDo) getSqlMapClient().queryForObject("Category.queryCategoryById",cateId);
	}
	
}